 <!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    

    <title>{$Think.config.site.title} - 订单改价</title>

    <meta name="keywords" content="{$Think.config.site.keywords}">

    <link href="{$Think.config.site.resource_url}css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/animate.min.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/style.min.css?v=4.0.0" rel="stylesheet">

</head>
<style>
#listtable .fa{
	cursor:pointer;
	color:#1ab394;
	margin-right:1em;
}
th .tag{font-size: 12px; color: #e66c6c; font-weight: normal;}
.ibox-title .tag{font-size: 12px; color: #e66c6c; font-weight: normal; display: inline-block; margin-left: 20px;}
.specval-hide{display: none;}

.btn-group{ font-size:0}
.btn-group .btn{ margin-left:-1px}
.btn-group .btn:not(:first-child):not(:last-child):not(.dropdown-toggle){ border-radius:0}
.btn-group > .btn:first-child:not(:last-child):not(.dropdown-toggle){border-bottom-right-radius: 0;border-top-right-radius: 0}
.btn-group > .btn:last-child:not(:first-child),.btn-group > .dropdown-toggle:not(:first-child) {border-bottom-left-radius: 0;border-top-left-radius: 0}

</style>
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
		<div class="row">
          <div class="col-sm-12">
                <div class="float-e-margins">
					<div class="ibox-title">
                        <h5>订单信息<span class="text-danger"></span></h5>
                    </div>
                    <div class="ibox-content">
						<table class="table table-bordered" id="listtable">
							<thead>
								<tr>
									<th width="">订单号</th>
									<th width="">买家姓名</th>
									<th width="">联系电话</th>
									<th width="">下单时间</th>
									<th width="">订单金额</th>
									<th width="">支付金额</th>
								</tr>
							</thead>
							<tbody>
								<tr class="order" data-order_id="{$order.order_id}">
									<td>{$order.order_no}</td>
									<td>{$order.receiver_name}</td>
									<td>{$order.receiver_mobile}</td>
									<td>{$order.create_time}</td>
									<td>{$order.order_money}</td>
									<td>{$order.pay_money}</td>
								</tr>
							</tbody>
						</table>
                    </div>
                </div>
            </div>
        </div>
		<div class="row">
          <div class="col-sm-12">
                <div class="float-e-margins">
					<div class="ibox-title">
                        <h5>商品改价 <span class="text-danger">（修改商品单价后会自动计算商品总价，如果降价则自动退款，加价的用户需要补价支付）</span></h5>
                    </div>
                    <div class="ibox-content">
						<table class="table table-striped">
							<thead>
								<tr>
									<th>商品图片</th>
									<th>商品名</th>
									<th>单价</th>
									<th>数量</th>
									<th>小计</th>
									<th>改价金额</th>
								</tr>
							</thead>	
							<tbody>
								{volist name="goods" id="vo"}
									<tr class="goods" data-specval_id="{$vo.goods_specval_id}">
										<td><img src="{$vo.goods_picture}" width="30" height="30"/></td>
										<td>（{$vo.brand_name}）{$vo.goods_name}【{$vo.goods_specval_name}】</td>
										<td align="right">{$vo.price}</td>
										<td align="center" class="num">{$vo.num}</td>
										<td align="right">￥{:number_format($vo['price']*$vo['num'],2)}</td>
										<td><input type="text" class="form-control good_num" name="price" placeholder="商品单价改为"></td>
									</tr>
								{/volist}
							</tbody>
						</table>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
          <div class="col-sm-12">
                <div class="ibox float-e-margins">
					<div class="ibox-title">
                        <h5>订单额外改价 <span class="text-danger">（负数表示平台需要退的款，正数表示用户需要补的款）</span></h5>
                    </div>
                    <div class="ibox-content">
                    	<div class="row form-horizontal">
						<div class="form-group">
                            <label class="col-sm-2 control-label text-right">改价金额：</label>
                            <div class="col-sm-6">
                                <input id="price" class="form-control" type="text" value="">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label text-right">改价备注：</label>
                            <div class="col-sm-6">
                                <textarea class="form-control" id="remark"></textarea>
                            </div>
                        </div>
                        <div class="form-group">
                        	<label class="col-sm-2 control-label text-right"> </label>
                            
                            <div class="col-sm-6">
                                <button class="btn btn-primary" id="save">提交</button>
                            </div>
                        </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="{$Think.config.site.resource_url}js/jquery.min.js?v=2.1.4"></script>
    <script src="{$Think.config.site.resource_url}js/bootstrap.min.js?v=3.3.5"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/peity/jquery.peity.min.js"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/iCheck/icheck.min.js"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/layer/layer.js"></script>
    <script src="{$Think.config.site.common_resource_url}js/majax.js"></script>
    <script src="{$Think.config.site.common_resource_url}js/jedit.js"></script>
    <script src="{$Think.config.site.common_resource_url}js/jquery.jeditable.js"></script>
</body>

</html>
<script>
$('#save').click(function(){
	var data={goods:[],price:0,remark:'',orderID:0},submit=true;
	$('tr.goods').each(function() {
		var inp = $(this).find('input[name="price"]'), price = $.trim(inp.val()),num = parseInt($(this).find('.num').text()),specval_id=$(this).data('specval_id');
		if (price!='') {
			if (isNaN(price)) {submit=false;layer.msg('价格请填写数字',{icon: 2});inp.focus(); return true;}
			data.goods.push({specval_id:specval_id,num:num,price:price});
		}
	})
	if (!submit) {return false;}
	data.orderID = $('tr.order').data('order_id');
	data.price = $('#price').val();
	data.remark = $('#remark').val();

	majax('{:url("changePrice")}',data,function(e){
		if (e.code>0) {
			window.parent.editSuccess(e);
		}else{
			layer.msg(e.msg,{icon:2});
		}
	})
})
</script>